﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HauhaltsPlaner
{
    public partial class Form2 : Form
    {
        Dictionary<String,Control> forms = new Dictionary<String,Control>();

        int currentRowIndex = 3;
        int currentButtonIndex = 0;
        int currentColumnIndex = 4;
        int currentTabIndex = 9;

        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            forms.Add("genNrLabel"+currentButtonIndex,new System.Windows.Forms.Label());
            forms.Add("genCBStatement"+currentButtonIndex,new System.Windows.Forms.ComboBox());
            forms.Add("genCBColumn"+currentButtonIndex,new System.Windows.Forms.ComboBox());
            forms.Add("genCBOperator"+currentButtonIndex,new System.Windows.Forms.ComboBox());
            forms.Add("genText"+currentButtonIndex,new System.Windows.Forms.TextBox());
            forms.Add("genButton"+currentButtonIndex,new System.Windows.Forms.Button());

            this.tableLayoutPanel1.SuspendLayout();
            this.SuspendLayout();

            // 1
            Label label1 = (Label)forms["genNrLabel" + currentButtonIndex];
            label1.Dock = System.Windows.Forms.DockStyle.Fill;
            label1.Name = "genNrLabel" + currentButtonIndex;
            label1.TabIndex = 0;
            label1.Text = currentRowIndex.ToString();
            label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;

            // 2
            ComboBox combo1 = (ComboBox)forms["genCBStatement" + currentButtonIndex];
            combo1.Dock = System.Windows.Forms.DockStyle.Top;
            combo1.FormattingEnabled = true;
            combo1.Name = "genCBStatement" + currentButtonIndex;
            combo1.TabIndex = ++currentTabIndex;

            // 3
            ComboBox combo2 = (ComboBox)forms["genCBColumn" + currentButtonIndex];
            combo2.Dock = System.Windows.Forms.DockStyle.Top;
            combo2.FormattingEnabled = true;
            combo2.Name = "genCBColumn" + currentButtonIndex;
            combo2.TabIndex = ++currentTabIndex;

            // 4
            ComboBox combo3 = (ComboBox)forms["genCBOperator" + currentButtonIndex];
            combo3.Dock = System.Windows.Forms.DockStyle.Top;
            combo3.FormattingEnabled = true;
            combo3.Name = "genCBOperator" + currentButtonIndex;
            combo3.TabIndex = ++currentTabIndex;

            // 5
            TextBox text1 = (TextBox)forms["genText" + currentButtonIndex];
            text1.Dock = System.Windows.Forms.DockStyle.Top;
            text1.Name = "genText" + currentButtonIndex;
            text1.TabIndex = ++currentTabIndex;

            // 6
            Button button1 = (Button)forms["genButton" + currentButtonIndex];
            button1.Dock = System.Windows.Forms.DockStyle.Top;
            button1.Name = "genButton" + currentButtonIndex;
            button1.TabIndex = ++currentTabIndex;
            button1.Text = "Add Statement";
            button1.UseVisualStyleBackColor = true;
            button1.Click += new System.EventHandler(this.button1_Click);

            currentButtonIndex++;

            this.tableLayoutPanel1.RowCount = currentColumnIndex;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());

            this.tableLayoutPanel1.Controls.Add(label1, 0, currentColumnIndex);
            this.tableLayoutPanel1.Controls.Add(combo1, 1, currentColumnIndex);
            this.tableLayoutPanel1.Controls.Add(combo2, 2, currentColumnIndex);
            this.tableLayoutPanel1.Controls.Add(combo3, 3, currentColumnIndex);
            this.tableLayoutPanel1.Controls.Add(text1, 4, currentColumnIndex);
            this.tableLayoutPanel1.Controls.Add(button1, 5, currentColumnIndex);

            currentColumnIndex++;
            currentRowIndex++;

            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.ResumeLayout(false);
        }
    }
}
